package org.peterf.foxish.component.updater;

import org.peterf.foxish.component.property.Updatable;
import org.peterf.foxish.component.updater.interfaces.Gradual;
import org.peterf.foxish.component.updater.interfaces.Updater;

public class LinearUpdater implements Updater {

    private float period;

    private Gradual updater;

    public LinearUpdater(Gradual updater, float period) {
        this.updater = updater;
        this.period = period;
    }

    public boolean isFinished() {
        return updater.isFinished();
    }

    public void reset() {
        updater.reset();
    }

    public void update(Updatable updatable, float elapsed) {
        updater.setProgress(updater.getProgress() + elapsed / period);
        updater.update(updatable, elapsed);
    }

}
